<?php

namespace app\index\model;

use think\Model;

class Paf extends Model {
    /**
     * 显示聘用人事的用户信息，连接user表，外键user的id，判断登录用户，连接用户情况表，外键表id，查询字段放回数据
     * @copyright hyw
     * @param $userId
     * @return Paf
     */
    public function getMaAttr($userId) {
        return $this
            ->alias('p')
            ->where('p.user_id','=',$userId)
            ->join(['user' => 'u'],'u.user_id = p.user_id')
            ->join(['userstatus' => 'us'],'us.userstatus_id = p.userstatus_id')
            ->field(['u.user_id','u.header','u.username','us.exp_job'])
            ->where('check','=',null)
            ->where('p.is_delete','=',0)
            ->select();
    }

    /**
     * 获取人事申请的id接口：判断前端传的user_id
     * @copyright hyw
     * @param $userId
     * @return Paf
     */
    public function getMatterIdAttr($userId) {
        return $this
            ->where('user_id','=',$userId)
            ->field('paf_id')
            ->find();
    }
}